package com.gitee.fsmxm.thinking.in.spring.ioc.overview.container;

import com.gitee.fsmxm.thinking.in.spring.ioc.overview.domain.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * {@link BeanFactory} 作为 ioc 容器 demo
 */
public class BeanFactoryAsIocContainerDemo {

    public static void main(String[] args) {
        // 声明容器
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        BeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
        // 装载配置
        int countOfBeans = beanDefinitionReader.loadBeanDefinitions("classpath:/META-INF/dependency-lookup-context.xml");

        System.out.println(countOfBeans);

        System.out.println(beanFactory.getBean(User.class));
    }

}
